[ command not found

In this troubleshooting guide we learn how to fix [ command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

[: command not found

or when using sudo you get the following error message

sudo: [: command not found

Solutions to [: command not found

How To Fix [: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu [ is provided by coreutils package.

coreutils is:

This package contains the basic file, shell and text manipulation utilities which are expected to exist on every operating system.

Specifically, this package includes: arch base64 basename cat chcon chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false flock fmt fold groups head hostid id install join link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd readlink realpath rm rmdir runcon sha*sum seq shred sleep sort split stat stty sum sync tac tail tee test timeout touch tr true truncate tsort tty uname unexpand uniq unlink users vdir wc who whoami yes

To fix this problem, we can install more using the command below.

sudo apt-get -y install coreutils

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install coreutils.

sudo apt -y install coreutils

Or if you have aptitude installed you can use the following command.

sudo aptitude install coreutils

Summary

In this tutorial we learn how to fix [ command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.